﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class UserControls_ProfitabilitySolvency : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
      string id = Request.Params["id"];
      StockAnalysis analysis = new StockAnalysis();
      DataTable dt = analysis.GetProfitabilitySolvencyTable(id);
      gridviewProfitabilitySolvency.DataSource = ConvertSubFigures.Convert(dt);
      gridviewProfitabilitySolvency.DataBind();

      Graph g = new Graph();
      Dictionary<string, string[]> graphData = ConvertGraphData.Convert(dt);

      string[] year;
      string[] returnOnEquity;
      string[] roi;
      string[] equityRatio;
      
      graphData.TryGetValue("year", out year);
      
      graphData.TryGetValue("return_on_equity", out returnOnEquity);
      graphReturnOnEquity.InnerHtml = g.drawGraphOneAttributeWithFiveFigures(Dictionary.Translate("return_on_equity"), "XAxis", Abbreviations.getAbbreviations("return_on_equity"), returnOnEquity, year, false, true, false);

      graphData.TryGetValue("roi", out roi);
      graphRoi.InnerHtml = g.drawGraphOneAttributeWithFiveFigures(Dictionary.Translate("roi"), "XAxis", Abbreviations.getAbbreviations("roi"), roi, year, false, true, false);

      graphData.TryGetValue("equity_ratio", out equityRatio);
      graphEquityRatio.InnerHtml = g.drawGraphOneAttributeWithFiveFigures(Dictionary.Translate("equity_ratio"), "XAxis", Abbreviations.getAbbreviations("equity_ratio"), equityRatio, year, false, true, false);
    }
}